package cn.itcast.order;

import cn.itcast.feign.config.DefaultFeignConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


@MapperScan("cn.itcast.order.mapper")
@SpringBootApplication
// 默认全局配置,日志级别,  clients: 指定扫描的包
@EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration.class, clients = {cn.itcast.feign.clients.UserClient.class})
// 开启feign客户端
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    /**
     * 创建RestTemplate并注入Spring容器
     *
     * @return
     */
    @Bean
    @LoadBalanced // 负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    // 全体服务选择策略
    // @Bean
    // public IRule randomRule() {
    //     return new RandomRule(); // 使用随机rule
    // }

}